class AdminController < ApplicationController
  before_filter :check_admin, :except => :login

  in_place_edit_for(:blog, :title)
  in_place_edit_for(:blog, :signature)

  def login
    session[:leelay] = nil
    @admin = Admin.new
    if request.post?
      result = Admin.check(params[:admin][:name], params[:admin][:password])
      if result
        session[:leelay] = params[:admin][:name]
        redirect_to blog_admin_posts_path
      end
      render :action => :login unless result
    end
  end

  private

  def check_admin
    return redirect_to(:controller => '/admin', :action => 'login') unless session[:leelay]
  end

end
